package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.TransportInfoRequest;
import cn.stylefeng.guns.modular.business.service.TransportInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 漕运航运控制器
 *
 * @author zhangyaowen
 * @date 2021/10/28 16:51
 */
@RestController
@ApiResource(name = "漕运航运")
public class TransportInfoController {

    @Resource
    private TransportInfoService transportInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @PostResource(name = "添加", path = "/transportInfo/add")
    public ResponseData add(@RequestBody @Validated(TransportInfoRequest.add.class) TransportInfoRequest transportInfoRequest) {
        transportInfoService.add(transportInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @PostResource(name = "删除", path = "/transportInfo/delete")
    public ResponseData delete(@RequestBody @Validated(TransportInfoRequest.delete.class) TransportInfoRequest transportInfoRequest) {
        transportInfoService.del(transportInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @PostResource(name = "编辑", path = "/transportInfo/edit")
    public ResponseData edit(@RequestBody @Validated(TransportInfoRequest.edit.class) TransportInfoRequest transportInfoRequest) {
        transportInfoService.edit(transportInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @GetResource(name = "查看详情", path = "/transportInfo/detail")
    public ResponseData detail(@Validated(TransportInfoRequest.detail.class) TransportInfoRequest transportInfoRequest) {
        return new SuccessResponseData(transportInfoService.detail(transportInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @GetResource(name = "获取列表", path = "/transportInfo/list")
    public ResponseData list(TransportInfoRequest transportInfoRequest) {
        return new SuccessResponseData(transportInfoService.findList(transportInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @GetResource(name = "分页查询", path = "/transportInfo/page")
    public ResponseData page(String threeClassifyName ,String secondClassifyName) {
        return new SuccessResponseData(transportInfoService.findPage(threeClassifyName,secondClassifyName));
    }


    @GetResource(name = "漕运航运二级页面目录结构", path = "/transportInfo/findTran")
    public ResponseData findTran() {
        return new SuccessResponseData(transportInfoService.findTran());
    }

    @GetResource(name = "详细信息", path = "/transportInfo/toReview")
    public ResponseData toReview(String id) {

        return new SuccessResponseData(transportInfoService.toReview(id));
    }

}